<p>
    <?php echo $html->link('Edit Previous Registration', array('controller'=>'registrations','action'=>'resume')); ?>
</p>
<?php $javascript->link('jquery-1.3.2.min.js', false); ?>

<script type="text/javascript">
var num_teams = 1;
var num_individuals = 1;
var num_quizmasters = 1;
var num_housers = 1;
$(document).ready(function() {

    $("input").bind("keypress", function(e) {
        if (e.keyCode == 13) return false;
    });

    $("#add_team_button").click(function(){
        num_teams += 1;
        $('#teams tr:last').after(''+
           '<tr id="x_team'+num_teams+'">'+
           '    <td>Team</td>'+
           '    <td><input name="data[Team]['+num_teams+'][division]" type="radio" value="STVA" /></td>'+
           '    <td><input name="data[Team]['+num_teams+'][division]" type="radio" value="STVB" /></td>'+
           '    <td><input name="data[Team]['+num_teams+'][division]" type="radio" value="STR" /></td>'+
           '    <td><input name="data[Team]['+num_teams+'][division]" type="radio" value="YTVA" /></td>'+
           '    <td><input name="data[Team]['+num_teams+'][division]" type="radio" value="YTVB" /></td>'+
           '    <td><input name="data[Team]['+num_teams+'][division]" type="radio" value="YTRA" /></td>'+
           '    <td><input name="data[Team]['+num_teams+'][division]" type="radio" value="YTRB" /></td>'+
           '    <td><input name="data[Team]['+num_teams+'][division]" type="radio" value="RO" /></td>'+
           '    <td><input type="button" value="X" onclick="removeEntry(\'#x_team'+num_teams+'\'); return false;" /></td>'+
           '</tr>');
    });
    $("#add_individual_button").click(function(){
        num_individuals += 1;
        $('#individuals tr:last').after(''+
            '<tr id="x_individual'+num_individuals+'">'+
            '    <td><input name="data[Individual]['+num_individuals+'][name]" type="text" /></td>'+
            '    <td><input name="data[Individual]['+num_individuals+'][division]" type="radio" value="STVA" /></td>'+
            '    <td><input name="data[Individual]['+num_individuals+'][division]" type="radio" value="STVB" /></td>'+
            '    <td><input name="data[Individual]['+num_individuals+'][division]" type="radio" value="STR" /></td>'+
            '    <td><input name="data[Individual]['+num_individuals+'][division]" type="radio" value="YTVA" /></td>'+
            '    <td><input name="data[Individual]['+num_individuals+'][division]" type="radio" value="YTVB" /></td>'+
            '    <td><input name="data[Individual]['+num_individuals+'][division]" type="radio" value="YTR" /></td>'+
            '    <td><input type="button" value="X" onclick="removeEntry(\'#x_individual'+num_individuals+'\'); return false;" /></td>'+
            '</tr>');
    });
    $("#add_quizmaster_button").click(function(){
        num_quizmasters += 1;
        $('#quizmasters tr:last').after(''+
            '<tr id="x_quizmaster'+num_quizmasters+'">'+
            '    <td><input name="data[Quizmaster]['+num_quizmasters+'][name]" type="text" /></td>'+
            '    <td><input name="data[Quizmaster]['+num_quizmasters+'][can_do_STVA]" type="checkbox" /></td>'+
            '    <td><input name="data[Quizmaster]['+num_quizmasters+'][can_do_STVB]" type="checkbox" /></td>'+
            '    <td><input name="data[Quizmaster]['+num_quizmasters+'][can_do_STR]" type="checkbox" /></td>'+
            '    <td><input name="data[Quizmaster]['+num_quizmasters+'][can_do_YTVA]" type="checkbox" /></td>'+
            '    <td><input name="data[Quizmaster]['+num_quizmasters+'][can_do_YTVB]" type="checkbox" /></td>'+
            '    <td><input name="data[Quizmaster]['+num_quizmasters+'][can_do_YTRA]" type="checkbox" /></td>'+
            '    <td><input name="data[Quizmaster]['+num_quizmasters+'][can_do_YTRB]" type="checkbox" /></td>'+
            '    <td><input name="data[Quizmaster]['+num_quizmasters+'][can_do_RO]" type="checkbox" /></td>'+
            '    <td><input type="button" value="X" onclick="removeEntry(\'#x_quizmaster'+num_quizmasters+'\'); return false;" /></td>'+
            '</tr>');
    });
    $("#add_houser_button").click(function(){
        num_housers += 1;
        $('#housing tr:last').after(''+
            '<tr id="x_housee'+num_housers+'">'+
            '    <td><input name="data[Housee]['+num_housers+'][name]" type="text" /></td>'+
            '    <td><input name="data[Housee]['+num_housers+'][type]" type="radio" value="male-quizzer" /></td>'+
            '    <td><input name="data[Housee]['+num_housers+'][type]" type="radio" value="female-quizzer" /></td>'+
            '    <td><input name="data[Housee]['+num_housers+'][type]" type="radio" value="male-adult" /></td>'+
            '    <td><input name="data[Housee]['+num_housers+'][type]" type="radio" value="female-adult" /></td>'+
            '    <td><input name="data[Housee]['+num_housers+'][type]" type="radio" value="child" /></td>'+
            '    <td><input type="button" value="X" onclick="removeEntry(\'#x_housee'+num_housers+'\'); return false;" /></td>'+
            '</tr>');
    });
});

function removeEntry(id) {
    $(id).remove();
}
</script>

<?php echo $form->create(); ?>

	<h1>Bible Quizzing Tournament Registration</h1>

    <h2>1) Tournament Selection</h2>
    <?php
        echo $form->input('Registration.tournament_id', array('label'=>''));  
	?>
	<h2>2) Contact Information</h2> 
	<p> 
Enter information about your church and your quiz coach.  Please provide e-mail and phone number of the coach <u>who will be attending the tournament</u>, not the church's e-mail or phone.  We will use this information to contact you if the need arises.
	</p> 
	<table> 
        <tr> 
            <td>Church Name</td> 
            <td><input type="text" name="data[Registration][church_name]" /></td> 
            <td>Conference</td> 
            <td><input type="text" name="data[Registration][conference]" /></td> 
        </tr> 
        <tr> 
            <td>Coach Name</td> 
            <td><input type="text" name="data[Registration][coach_name]" /></td> 
            <td>Email Address</td> 
            <td><input type="text" name="data[Registration][email]" /></td> 
        </tr> 
        <tr> 
            <td>Daytime Phone</td> 
            <td><input type="text" name="data[Registration][daytime_phone]" /></td> 
            <td>Evening Phone</td> 
            <td><input type="text" name="data[Registration][evening_phone]" /></td> 
        </tr> 
	</table> 
	<br /> 
	<table> 
		<tr> 
			<td>Number of people eating lunch</td> 
			<td><input type="text" name="data[Registration][number_for_lunch]" size="5" /></td> 
		</tr> 
		<tr> 
			<td>Number working quiz seats you are bringing</td> 
			<td><input type="text" name="data[Registration][number_of_seats]" size="5" /></td> 
		</tr> 
	</table> 
	<br /> 
	<h2>3) Team Setup</h2> 
	<p> 
		Enter the division of each team participating.
	</p> 
	<table id="teams"> 
		<tr> 
			<th></th> 
			<th>S<br />T<br />V<br />A</th> 
			<th>S<br />T<br />V<br />B</th> 
			<th><br />S<br />T<br />R</th> 
			<th>Y<br />T<br />V<br />A</th> 
			<th>Y<br />T<br />V<br />B</th> 
			<th>Y<br />T<br />R<br />A</th> 
			<th>Y<br />T<br />R<br />B</th> 
			<th><br /><br />R<br />O</th> 
            <th></th>
		</tr> 
        <tr id="x_team1"> 
            <td>Team</td> 
            <td><input name="data[Team][1][division]" type="radio" value="STVA" /></td> 
            <td><input name="data[Team][1][division]" type="radio" value="STVB" /></td> 
            <td><input name="data[Team][1][division]" type="radio" value="STR" /></td> 
            <td><input name="data[Team][1][division]" type="radio" value="YTVA" /></td> 
            <td><input name="data[Team][1][division]" type="radio" value="YTVB" /></td> 
            <td><input name="data[Team][1][division]" type="radio" value="YTRA" /></td> 
            <td><input name="data[Team][1][division]" type="radio" value="YTRB" /></td> 
            <td><input name="data[Team][1][division]" type="radio" value="RO" /></td> 
            <td><input type="button" value="X" onclick="removeEntry('#x_team1'); return false;" /></td>
        </tr> 
	</table> 
	<input type="button" id="add_team_button" value="Add another team" /> 
	<br /> 
	<br /> 
	<h2>4) Individuals Setup</h2> 
	<p> 
		Enter the name and division of each quizzer participating in individual competition. 
	</p> 
	<table id="individuals"> 
		<tr> 
			<th>Name</th> 
			<th>S<br />T<br />V<br />A</th> 
			<th>S<br />T<br />V<br />B</th> 
			<th><br />S<br />T<br />R</th> 
			<th>Y<br />T<br />V<br />A</th> 
			<th>Y<br />T<br />V<br />B</th> 
			<th><br />Y<br />T<br />R</th> 
            <th></th>
		</tr> 
        <tr id="x_individual1"> 
			<td><input name="data[Individual][1][name]" type="text" /></td> 
			<td><input name="data[Individual][1][division]" type="radio" value="STVA" /></td> 
            <td><input name="data[Individual][1][division]" type="radio" value="STVB" /></td> 
            <td><input name="data[Individual][1][division]" type="radio" value="STR" /></td> 
            <td><input name="data[Individual][1][division]" type="radio" value="YTVA" /></td> 
            <td><input name="data[Individual][1][division]" type="radio" value="YTVB" /></td> 
            <td><input name="data[Individual][1][division]" type="radio" value="YTR" /></td> 
            <td><input type="button" value="X" onclick="removeEntry('#x_individual1'); return false;" /></td>
		</tr> 
	</table> 
	<input type="button" id="add_individual_button" value="Add another quizzer" /> 
	<br /> 
	<br /> 
	<h2>5) Quizmasters Setup</h2> 
	<p> 
		Enter the name of each quizmaster coming with your church, and check each of the divisions he or she is willing to quizmaster in.
	</p> 
	<table id="quizmasters"> 
		<tr> 
			<th>Name</th> 
			<th>S<br />T<br />V<br />A</th> 
			<th>S<br />T<br />V<br />B</th> 
			<th><br />S<br />T<br />R</th> 
			<th>Y<br />T<br />V<br />A</th> 
			<th>Y<br />T<br />V<br />B</th> 
			<th>Y<br />T<br />R<br />A</th> 
			<th>Y<br />T<br />R<br />B</th> 
			<th><br /><br />R<br />O</th> 
            <th></th>
		</tr> 
        <tr id="x_quizmaster1"> 
			<td><input name="data[Quizmaster][1][name]" type="text" /></td> 
			<td><input name="data[Quizmaster][1][can_do_STVA]" type="checkbox" /></td> 
			<td><input name="data[Quizmaster][1][can_do_STVB]" type="checkbox" /></td> 
			<td><input name="data[Quizmaster][1][can_do_STR]" type="checkbox" /></td> 
			<td><input name="data[Quizmaster][1][can_do_YTVA]" type="checkbox" /></td> 
			<td><input name="data[Quizmaster][1][can_do_YTVB]" type="checkbox" /></td> 
			<td><input name="data[Quizmaster][1][can_do_YTRA]" type="checkbox" /></td> 
			<td><input name="data[Quizmaster][1][can_do_YTRB]" type="checkbox" /></td> 
			<td><input name="data[Quizmaster][1][can_do_RO]" type="checkbox" /></td> 
            <td><input type="button" value="X" onclick="removeEntry('#x_quizmaster1'); return false;" /></td>
		</tr> 
	</table> 
	<input type="button" id="add_quizmaster_button" value="Add another quizmaster" /> 
	<br /> 
	<br /> 
	<h2>6) Housing Setup</h2> 
	<p> 
		Enter the name and type of each person who needs housing for your church.
	</p> 
	<table id="housing"> 
		<tr> 
			<th>Name</th> 
			<th>Male<br/>Quizzer</th> 
			<th>Female<br/>Quizzer</th> 
			<th>Male<br/>Adult</th> 
			<th>Female<br/>Adult</th> 
            <th><br/>Child</th>
            <th></th>
		</tr> 
        <tr id="x_housee1"> 
			<td><input name="data[Housee][1][name]" type="text" /></td> 
			<td><input name="data[Housee][1][type]" type="radio" value="male-quizzer" /></td> 
			<td><input name="data[Housee][1][type]" type="radio" value="female-quizzer" /></td> 
            <td><input name="data[Housee][1][type]" type="radio" value="male-adult" /></td> 
			<td><input name="data[Housee][1][type]" type="radio" value="female-adult" /></td> 
			<td><input name="data[Housee][1][type]" type="radio" value="child" /></td> 
            <td><input type="button" value="X" onclick="removeEntry('#x_housee1'); return false;" /></td>
		</tr> 
	</table> 
	<input type="button" id="add_houser_button" value="Add another person" /> 
    <br />
    <br />
    <h2>7) Notes</h2>
    <p>
        Registration Notes (bringing broken seats, one adult not eating lunch, roommate preferences, etc.):
        <textarea name="data[Registration][notes]" cols="60" rows="6"></textarea>
    </p>
    
<?php echo $form->end('Submit Registration'); ?>
